<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>

        function selectAll(num) {

            switch (num){
                case 0:
                    $("[type=checkbox]").prop("checked",true)
                    break
                case 1:
                    $("[type=checkbox]").prop("checked",false)
                    break
                case 2:
                    $("[type=checkbox]").each(function (index, ele) {
                        ele.checked = !ele.checked
                    })
                    break
            }
        }

        function delSelect() {

            $("[type=checkbox]:checked").each(function (index, ele) {
                $(ele).parent().parent().remove()
            })

        }

    </script>
</head>
<body>
全选、反选、全不选、删除选中行
<table cellspacing="0" border="1" width="100%">
    <tr>
        <th>
            <input type="button" value="全选" onclick="selectAll(0)"/>
            <input type="button" value="全不选" onclick="selectAll(1)"/>
            <input type="button" value="反选" onclick="selectAll(2)"/>
            <br/>
            <input type="button" value="删除选中" onclick="delSelect()"/>
        </th>
        <th>序号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>性别</th>
    </tr>
    <tr>
        <th>
            <input type="checkbox"/>
        </th>
        <th>1</th>
        <th>zhangsan</th>
        <th>123123123</th>
        <th>男</th>
    </tr>
    <tr>
        <th><input type="checkbox"/></th>
        <th>2</th>
        <th>lisi</th>
        <th>321321</th>
        <th>女</th>
    </tr>
    <tr>
        <th><input type="checkbox"/></th>
        <th>3</th>
        <th>王五</th>
        <th>321321</th>
        <th>女</th>
    </tr>
</table>
</body>
</html>